package com.hxd.otc.module.my.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.my.bean.ApplyRequestBean;
import com.hxd.otc.module.my.contract.CooperativeMerchantAccessContract;
import com.hxd.otc.module.my.model.ApplyModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

/**
 * Created by lzy on 2018/12/18 0018.
 * description ${合作商户接入 Presenter}
 */
public class CooperativeMerchantAccessPresenter extends BasePresenter<CooperativeMerchantAccessContract.IView> implements CooperativeMerchantAccessContract.IPresenter {

    private final ApplyModel mApplyModel;

    public CooperativeMerchantAccessPresenter(CooperativeMerchantAccessContract.IView iView) {
        super(iView);
        mApplyModel = ApplyModel.getInstance();
    }

    @Override
    public void onSubmitApplication(String name, String phone, String contactWay, String referrer) {
        mApplyModel.apply(ApplyRequestBean.createCooperativeMerchantAccessApply(name, phone, contactWay, referrer), new BaseObserver<String>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull String s) {
                mView.onSubmitApplicationSuccess();
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                mView.showToast(errMessage);
            }
        }, mView.<BaseBean<String>>bindAutoDispose());
    }
}
